package cn.itcast.oa.model;

import java.util.List;

/**
 * 分页数据存放的bean
 * @author 留得残荷听雨声
 *
 */
public class PageBean {
	
    private int pageSize;//每页的多少
    private int currentPage;//当前页面
    
    private int recordCount;//记录的总数量
    @SuppressWarnings("rawtypes")
	private List recordList;//记录数据
    
    private int pageCount;//页数
    private int beginPageIndex;//开始页数
    private int endPageIndex;//结束页数
    
    public PageBean(int currentPage,int pageSize,List recordList,int recordCount){
    	this.currentPage=currentPage;
    	this.pageSize=pageSize;
    	this.recordList=recordList;
    	this.recordCount=recordCount;
    	
    	pageCount=(recordCount+pageSize-1)/pageSize;
    	
    	/*算法求未知的数据*/
    	if(pageCount<=10){
    		beginPageIndex=1;
    		endPageIndex=10;
    	}else{
    		beginPageIndex=currentPage-4;
    		endPageIndex=currentPage+5;
    		if(beginPageIndex<1){
    			beginPageIndex=1;
    			endPageIndex=10;
    		}else if(endPageIndex>pageCount){
    			beginPageIndex=pageCount-9;
    			endPageIndex=pageCount;
    		}

    	}
    	
    }
    
    public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}
	public int getRecordCount() {
		return recordCount;
	}
	public void setRecordCount(int recordCount) {
		this.recordCount = recordCount;
	}
	public List getRecordList() {
		return recordList;
	}
	public void setRecordList(List recordList) {
		this.recordList = recordList;
	}
	public int getPageCount() {
		return pageCount;
	}
	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}
	public int getBeginPageIndex() {
		return beginPageIndex;
	}
	public void setBeginPageIndex(int beginPageIndex) {
		this.beginPageIndex = beginPageIndex;
	}
	public int getEndPageIndex() {
		return endPageIndex;
	}
	public void setEndPageIndex(int endPageIndex) {
		this.endPageIndex = endPageIndex;
	}
	
}
